package com.fyt.reachgo.Repository;

import com.fyt.reachgo.domain.TravelGuide;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

// TravelGuideRepository.java
public interface TravelGuideRepository extends JpaRepository<TravelGuide, Integer> {

    /**
     * 根据目的地和天数查询路书（按点赞数降序）
     * 自动映射到 travel_guide 表
     */
    @Query("SELECT g FROM TravelGuide g " +
            "WHERE g.title like :title " +
            "AND g.days = :days " +
            "ORDER BY g.likes DESC")
    List<TravelGuide> findByDestinationAndDays(
            @Param("title") String title,
            @Param("days") int days
    );
}
